<template>
	<view class="wrap">
		<view class="top-wrapper flex flex-h-start flex-v-end">
			<view class="top flex flex-between flex-v-center" v-if="token">
				<view class="lt flex flex-h-start flex-v-center">
					<image :src="headImg" v-if="headImg"></image>
					<image src="../../static/image/head.png" v-else></image>
					<view class="nickname-mobile  flex-col flex-between flex-v-start">
						<text class="nickname">{{nickname}}</text>
						<view class="mobile">{{mobile}}</view>
					</view>
				</view>
				<view class="rt" @click="loginOut">
					退出登录
				</view>
				
			</view>
			<view class="top" v-else>
				<view class="top flex flex-h-start flex-v-center">
					<image src="../../static/image/head.png"></image>
					<view class="login"   @click="jump(0)">登录/注册</view>
				</view>
			</view>
		</view>
		<view class="bottom">
			<u-cell-group>
				<u-cell-item title="我的挪车码" @click="jump(1)">
					<view slot="icon">
						<image src="../../static/image/car.png"></image>
					</view>
				</u-cell-item>
				<u-cell-item title="我的收藏" @click="jump(2)">
					<view slot="icon">
						<image src="../../static/image/collect.png"></image>
					</view>
				</u-cell-item>
			</u-cell-group>
		</view>
		<!-- <u-popup v-model="authorize" mode="center" border-radius="10">
			<view class="pop">
				<text >需要获取获取手机号</text>
				<view class="flex flex-v-center flex-between">
					<button class="sure" open-type="getPhoneNumber"
						@getphonenumber="getPhoneNumber">确定</button>
					<button class="cancel">取消</button>
				</view>
				
				
			</view>
			
		</u-popup> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				openid: "",
				headImg:'',
				token:'',
				nickname:'昵称',
				mobile:''
			}
		},
		onShow() {
			this.token = uni.getStorageSync('token');
			console.log(this.token)
			this.headImg = uni.getStorageSync('headImg');
			this.mobile = uni.getStorageSync('mobile');
			this.nickname = uni.getStorageSync('nickname');
			// if(!this.token){
			// 	uni.navigateTo({
			// 		url:"../login/login"
			// 	})
			// }
		},
		
		methods: {
			
			
			jump(type) {
				if (type == 0) {
					uni.navigateTo({
						url: "../login/login"
					})
				}
				if (type == 1) {
					if(uni.getStorageSync('codeImg')&&this.token){
							uni.navigateTo({
								url:"../playbill"
						})
					}else{
						uni.navigateTo({
							url: "../code"
						})
					}
					
				}
				if (type == 2) {
					uni.navigateTo({
						url: "../collect"
					})
				}
			},
			loginOut(){
				this.LoadingMsg('退出成功');
				setTimeout(() => {
					uni.hideLoading();
					uni.removeStorageSync("token")
					uni.navigateTo({
						url:"../login/login"
					})
				}, 1500);
			}
		}
	}
</script>

<style scoped lang="scss">
	.wrap {
		.pop{
			width: 600rpx;
			height: 300rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			align-items: center;
			text{
				color: #333;
				font-size: 36rpx;
				font-weight: 600;
				text-align: center;
				padding-top: 80rpx;
			}
			view{
				button{
					width: 300rpx;
				}
			}
			.sure{
				color: #3268FC;
				border: none;
			}
			.cancel{
				color: #999;
				border: none;
			}
		}
		.top-wrapper {
			background: #3268FC;
			height: 330rpx;
			padding: 0 50rpx 45rpx 50rpx;
			.top {
                width: 100%; 
				image {
					width: 100rpx;
					height: 100rpx;
					border-radius: 100%;
				}
                .nickname-mobile{
					padding-left: 25rpx;
					.nickname{
						color: #fff;
						font-size: 30rpx;
					}
					.mobile{
						color: #fff;
						font-size: 30rpx;
						padding-top: 10rpx;
					}
				}
				.rt{
					color: #fff;
					font-size: 30rpx;
				}
				.login {
					padding-left: 38rpx;
					color: #fff;
					font-size: 30rpx;
				}
			}
		}

		.bottom {
			/deep/.u-cell_title {
				font-size: 30rpx;
				font-family: HiraginoSansGB-W3;
				color: #000000;
				padding-left: 10rpx;
			}

			/deep/.u-cell {
				image {
					width: 32rpx;
					height: 32rpx;
					position: relative;
					top: 2rpx;
				}
			}
		}
	}
</style>
